from flask import Blueprint
from ...models import Category, Link, Article


home_bp = Blueprint(
    'home',
    __name__,
    url_prefix='',
    template_folder='templates',
    static_folder='skin',
    static_url_path='/skin'
)


@home_bp.context_processor
def _all():
    menus = Category.query.filter_by(parent_id=0)
    links = Link.query
    focus = Article.query.filter_by(status=True, focus=True).order_by(Article.id.desc())
    return dict(menus=menus, links=links, focus=focus)


from . import index, category, article, tag
